let taskInit = {
}

let quizzesInfoInit = {
  content: [],
  totalElements: 0
}

export default (state = {
  task: taskInit,
  assignments: [],
  quizzesInfo: quizzesInfoInit,
  assignment: {}
}, action) => {
  switch (action.type) {
    case 'REFRESH_TASK':
      return Object.assign({}, state, {task: action.taskInfo})
    case 'GET_ASSIGNMENTS':
      const assignments = action.assignments
      return Object.assign({}, state, {assignments: assignments})

    case 'GET_ASSIGNMENT_QUIZZES':
      return Object.assign({}, state, {quizzesInfo: action.data})

    case 'GET_ASSIGNMENT':
      const assignment = action.data
      return Object.assign({}, state, {assignment: assignment})
    default:
      return state
  }
}
